<%--
 *  File:    ProtocolDetailMain.jsp
 *  @Author: AlexBi
 *  Date:    2010/03/08
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<% //--------------------------------------  setting logger --%>


<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "PCM";
 	String strTableName = "";
	String privilegeCode = "11201";    
    String contextPath = request.getContextPath(); 
%>

<% //--------------------------------------  include files list --%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>ProtocolDetailMain</title>
<PageFlow:CheckPageFlow pageName="p_protocoldetail"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>

<%@ include file="/inc/SummaryDivision.inc" %>

<% //--------------------------------------  output variant from pageflow --%>
<%
  	Vector totalsummary = (Vector)pageContext.getAttribute("protocoldetail");
  	if(totalsummary == null)
  	{
  		totalsummary = new Vector();
  	}
%>

<script language="JavaScript" >

function page_add(){
	if(!checkForm(cform))   return; 
    if(cform.agency.value=="Y")
      {
       	if(cform.salestarget.value=="" || cform.salestarget.value == "0"|| cform.salestarget.value < 0)
			{
				alert("<%= message.getMessageDesc("Agency_Protocol_saletarget_more_then_zero") %>");
				return;
			}
       }

     cform.actionname.value = "add";
  	 cform.target = "_self";
  	 isRunning = true;
  	 cform.submit();
}

function page_delete(){
    if(isNullChecked(cform.deleteids))
    {
        alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>");
        return;
    }
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>")) return;
    
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
}
function page_setproduct(id,umcode,prodcode,prodname){
	document.cform.prodid.value=id;
	document.cform.productname.value=prodname;
}
</script>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="cform" method="post" action="<%=contextPath %>/Dispatcher">
<input type="hidden" name="pagename" value="p_protocoldetail">
<input type="hidden" name="actionname">
<custom:hidden name="userinfo" property="orgid" scope="session"/>
<custom:hidden name="userinfo" property="userid" changedName="maker" scope="session"/>
<custom:hidden property="agency"/>
<custom:hidden property="protocolid"/>
<%
	String agency = (String)pageContext.getAttribute("agency");
	String protocoltypename = (String)pageContext.getAttribute("protocoltypename");
	if(!"N".equals(agency)){
%>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
      <tr>
        <td>
          <table width="100%" border="0" cellspacing="0">
             <tr>
             	<td class="td_right">
             	          <a onclick="page_add();"><custom:button type="2" label="L_Add" imgsrc="add_btn.gif" border="0"/></a>
                     <%if(totalsummary.size() > 0){%>
                          <a onclick="page_delete();"><custom:button type="2" label="L_Delete" imgsrc="delete_btn.gif" border="0"/></a>
                     <%}%>
             	</td>
             </tr>
          </table>
        </td>
      </tr>
</table>
<%}%>
<table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
        <tr class="deepblue-left" >
		  <td class="title_center">&nbsp;</td>
          <td class="title_center" width="40%"><%= label.getLabelName("L_Product") %> <span class="red">*</span> </td>
          <td class="title_center" width="30%"><%= label.getLabelName("L_Price") %></td>
          <td class="title_center" width="30%"><%= label.getLabelName("L_SalesTargets") %></td>
        </tr>
		 <% //--------------------------------------  default value definition --%>
          	<%
            	int i = 0;
             	String strClassType = new String();
          	%>

          	<% //--------------------------------------  loop results --%>
		<logic:iterate id="onerow" collection="<%= totalsummary %>" indexId="idx">
           	<%
            	HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
           		Integer prodid = (Integer)tempMap.get("prodid");
           		boolean isAster = new Integer(2).equals(prodid);
            	if(i%2 == 1)
            	{
              		strClassType = "td-listrom";
            	}else{
              		strClassType = "";
            	}
            	i++;
          	%>
          	<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  class="none">
          		<%if(isAster){ %>
          			<td width="5" class="title_center">
	              		&nbsp;
	            	</td>
            	<%}else{ %>
            		<td width="5" class="title_center">
	              		<input type="checkbox" name="deleteids" value="<%=JspHelper.filterNull( tempMap.get("protocolproductid") )%>" class="checkbox">
	            	</td>
            	<%} %>
            	<td class="title_center">
            		<custom:write name="onerow" property="prdn" nbsp="true" />
            	</td>
            	<td class="title_center">
            		<custom:write name="onerow" property="listprice"  nbsp="true"/>
            	</td>
            	<td class="title_center">
            		<custom:write name="onerow" property="salestarget"  nbsp="true"/>
            	</td>

     		 </tr>
     	 </logic:iterate>
     	 
<!--     	 newdetail            -->
<%
	
	if(!"N".equals(agency)){
%>
      <tr class="none">
            <td class="title_center">&nbsp;</td>
            <td class="title_center">
				<custom:hidden name="newdetail" property="prodid" command="notnull" label="L_Product"/>
            	<custom:text name="newdetail" property="productname" size="40" readonly="true" style="border:1px #7F9DB9 solid; width:200px;"/>
					<a onclick="window.open ('../../phap.datp/masterdata/kdm/ProductSelect.jsp?promotion=3', 'newwindow', 'height=400, width=600, top=100, left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')"><input type="button" class="button3" value="*"> </a>
            </td>
            <td class="title_center">
            	<custom:text name="newdetail" property="listprice" label="L_Price" size="10" command="notnegative"  dataType="double" dataFormatName="amountformat" style="border:1px #7F9DB9 solid; width:60px;"/>
            </td>
            <td class="title_center">
            	<custom:text name="newdetail" property="salestarget" label="L_SalesTargets" size="10"  command="notnegative"  dataType="double" dataFormatName="amountformat" style="border:1px #7F9DB9 solid; width:60px;" />
            </td>
            
      </tr>
<%} %>
 </table>     

</form>
</body>
</html>